/** \file    CentresTree.cpp
  * \brief   Produces tree (for fast search) with mapping: segment centre to its index.
  * \date    2002 - 2003
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/segm/src/CentersTree.cpp,v 1.2 2005/04/04 04:10:16 cscom1r4 Exp $
  */

#include "segm/Segmentation.h"
#include "segm/VecInd.h"
#include "xtd/kDimTree.h"

void Segmentation::centresTree(VecIndTree & t)
{
	//load moved-centers of s segments in a tree
	positions();
	std::vector<VecInd> load(count());
	int i;
	for (i = 0; i != count(); ++i) {
		Segment & g = segmentByIndex(i);
		double_point sum = g.centre + double_point(g.adisplacement());
		load[i].x = sum.x;
		load[i].y = sum.y;
		load[i].ind = i;
	}
	t.Create(&*load.begin(), load.size());
}
